#!/bin/bash


FILE="${PROJECT}_artifact.tar.gz"
APP_LOCATION=${DEPLOY_HOME}/${PROJECT}

echo "> extract package:"
echo "${PWD}/${FILE}"

if [ -f "${FILE}" ]; then
    if [ -d "${APP_LOCATION}" ]; then
        rm -rf ${APP_LOCATION}
    fi
    mkdir -p ${APP_LOCATION}
    tar zxvf ${FILE} -C ${APP_LOCATION}
    echo "> package extracted"
else
    echo "> package not exists!"
    exit 1
fi

# replace config
echo "> replace config ..."
cp sys.${BRANCH}.config ${APP_LOCATION}/mms/releases/1/sys.config

if [ $? = 0 ]; then
    echo "> done."
else
    echo "> failed!"
    exit 1
fi


